﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Truextend.Common.Data;
using Truextend.Training.Model.Entities;

namespace Truextend.Training.Model.Tests
{
    [TestClass]
    public class CourseRepositoryTests :BaseTestClass
    {
        [Priority(1), TestMethod]
        public void AddCourseTest()
        {
            int beforeInset = 0;
            int afterInsert = 0;
            Repository<Course> courseRepository = null;
            ExecuteManager(uow =>
                                {
                                    courseRepository = new Repository<Course>(uow);
                                    var course = new Course
                                                     {
                                                         Name = "Course 1",
                                                         Category = "Programming",
                                                         DirectedTo = "Developers",
                                                         Prerequisites = "Course x",
                                                         Contents = "blah blah...."
                                                     };
                                    beforeInset = courseRepository.GetCount();
                                    courseRepository.Add(course);
                                }, () =>
                                       {
                                           afterInsert = courseRepository.GetCount();
                                       }
                );
            Assert.AreEqual(beforeInset + 1, afterInsert);

        }
    }
}
